<?php
exit('used');
require dirname(__file__).'/core/core.php';
$data = unserialize(file_get_contents($_SERVER['DOCUMENT_ROOT'] .'/d'));

$Eleanor = Eleanor::getInstance();
$values = [];
foreach ($data as $k => $v) {
	$R = Eleanor::$Db->Query('SELECT MAX(`pos`) FROM `el_question_categories` WHERE `parent`= "0"');
	list($pos) = $R->fetch_row();
	$values = array(
		'parent' => 0,
		'parents' => null,
		'published' => 1,
		'pos' => ($pos === null ? 1 : $pos + 1),
	);
	$id = Eleanor::$Db->Insert('el_question_categories', $values);
	Eleanor::$Db->Insert('el_question_categories_l', array(
		'id' => $id,
		'language' => '',
		'title' => $k,
		'uri' => $Eleanor->Url->Filter(htmlspecialchars_decode($k, ELENT)),
	));
	if (is_array($v)) {
		foreach ($v as $v2) {
			$R = Eleanor::$Db->Query('SELECT MAX(`pos`) FROM `el_question_categories` WHERE `parent`= "'. $id .'"');
			list($pos) = $R->fetch_row();
			$values = array(
				'parent' => $id,
				'parents' => $id .',',
				'published' => 1,
				'pos' => ($pos === null ? 1 : $pos + 1),
			);
			$id_in = Eleanor::$Db->Insert('el_question_categories', $values);
			Eleanor::$Db->Insert('el_question_categories_l', array(
					'id' => $id_in,
					'language' => '',
					'title' => $v2,
					'uri' => $Eleanor->Url->Filter(htmlspecialchars_decode($v2, ELENT)),
				));
		}
	}
}
dump('x');